From 6ba552bc563d49ec14414070d95ddf0ff171f3ea Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 27 Jun 2008 17:05:27 +0000 Subject: [PATCH] Warning cleanup. Restore functionality of 'no garmin devices found' for now. --- gpsbabel/garmin.c | 2 +- gpsbabel/garmin_device_xml.c | 16 +++++++++++----- gpsbabel/garmin_device_xml.h | 8 ++++---- gpsbabel/jeeps/gpslibusb.c | 3 ++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 997db4577..1336ec18f 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -253,7 +253,7 @@ rd_init(const char *fname) { if (setjmp(gdx_jmp_buf)) { char *vec_opts = NULL; - gdx_info *gi = gdx_get_info(); + const gdx_info *gi = gdx_get_info(); gpx_vec = find_vec("gpx", &vec_opts); gpx_vec->rd_init(gi->from_device.canon); } else { diff --git a/gpsbabel/garmin_device_xml.c b/gpsbabel/garmin_device_xml.c index 268670f69..0e7222b0a 100644 --- a/gpsbabel/garmin_device_xml.c +++ b/gpsbabel/garmin_device_xml.c @@ -105,9 +105,15 @@ static xg_tag_mapping gdx_map[] = { const gdx_info * gdx_read(const char *fname) { - xml_init(fname, gdx_map, NULL); - xml_read(); - xml_deinit(); + // Test file open-able before gb_open gets a chance to fatal(). + FILE *fin = fopen(fname, "r"); + + if (fin) { + fclose(fin); + xml_init(fname, gdx_map, NULL); + xml_read(); + xml_deinit(); + } return my_gdx_info; } @@ -119,8 +125,8 @@ gdx_find_file(char **dirlist) { const gdx_info *gdx; while (*dirlist) { char *tbuf; - xasprintf(&tbuf, "%s/%s", dirlist, "GarminDevice.xml"); - mountpoint = dirlist; + xasprintf(&tbuf, "%s/%s", *dirlist, "GarminDevice.xml"); + mountpoint = *dirlist; gdx = gdx_read(tbuf); xfree(tbuf); if (gdx) { diff --git a/gpsbabel/garmin_device_xml.h b/gpsbabel/garmin_device_xml.h index bc90ecd87..ffc6b31af 100644 --- a/gpsbabel/garmin_device_xml.h +++ b/gpsbabel/garmin_device_xml.h @@ -24,10 +24,10 @@ * Describes a file on the unit. */ typedef struct { - const char *path; - const char *basename; - const char *extension; - const char *canon; // full name, when applicable. + char *path; + char *basename; + char *extension; + char *canon; // full name, when applicable. } gdx_file; /* diff --git a/gpsbabel/jeeps/gpslibusb.c b/gpsbabel/jeeps/gpslibusb.c index 20b531381..3ddb08464 100644 --- a/gpsbabel/jeeps/gpslibusb.c +++ b/gpsbabel/jeeps/gpslibusb.c @@ -325,7 +325,8 @@ int garmin_usb_scan(libusb_unit_data *lud, int req_unit_number) * that is wants to read and write GPX files on a * mounted drive. Try that now. */ - gdx = gdx_find_file("."); +char *dlist[] = { ".", NULL}; + gdx = gdx_find_file(dlist); if (gdx) return 1; /* Plan C. */ fatal("Found no Garmin USB devices.\n"); -- 2.30.2